package hku.cs.lunuo.voter.impl;

import hku.cs.lunuo.rank.DefaultLabel;
import hku.cs.lunuo.rank.model.Label;
import hku.cs.lunuo.voter.VotedGlobal;
import hku.cs.lunuo.voter.VotedUnit;
import hku.cs.lunuo.voter.Voter;

public class Kulczynski2Minos extends Voter {

	@Override
	public Label vote(VotedUnit u, VotedGlobal g) {
		int falseCases = u.tf.getFlsTimes();
		int trueCases = u.tf.getTruTimes();
		float susc;

		susc = ((float)falseCases/g.getTotalFls()+(float)falseCases/(falseCases+trueCases))/2;
		
		float noise;
		
		if(g.getTotalFls()==falseCases)
			noise = 0;
		else
			noise = ((float)(g.getTotalFls()-falseCases)/g.getTotalFls()
				+(float)(g.getTotalFls()-falseCases)/(g.getTotalFls()-falseCases+g.getTotalTru()-trueCases))/2;
		
		return new DefaultLabel(susc-noise);
	}

}
